//
//  OMSearchHistoryItemCollectCell.m
//  OMENGO_NEW
//
//  Created by 梁尚嘉 on 2017/4/21.
//  Copyright © 2017年 Kamfat. All rights reserved.
//

#import "OMSearchHistoryItemCollectCell.h"
#import <YYText/YYText.h>
#import "NSAttributedString+SizeRemind.h"
@interface OMSearchHistoryItemCollectCell()
@property (nonatomic, strong) UILabel *elementLabel;
@end
@implementation OMSearchHistoryItemCollectCell

#define kFont SM_CFont(28)
- (void)configure
{
    [super configure];
    _elementLabel = [UILabel new];
    _elementLabel.font = kFont;
    _elementLabel.textColor = SM_blackColor;
    _elementLabel.layer.cornerRadius = 3;
    _elementLabel.layer.borderColor = SM_blackColor.CGColor;
    _elementLabel.layer.borderWidth = 1.0f;
    _elementLabel.backgroundColor = HEXCOLOR(@"#FFFAC0");
    _elementLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_elementLabel];

    self.isHot = NO;
}

- (void)setIsHot:(BOOL)isHot
{
    _isHot = isHot;
    if (isHot) {
        _elementLabel.layer.borderColor = SM_blackColor.CGColor;
        _elementLabel.backgroundColor = HEXCOLOR(@"#FFFAC0");
    }else {
        _elementLabel.layer.borderColor = HEXCOLOR(@"#D6D6D6").CGColor;
        _elementLabel.backgroundColor = [UIColor clearColor];
    }
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.elementLabel.frame = self.bounds;
}

- (void)configureCellWithObj:(id)obj
{
    if ([obj isKindOfClass:[NSString class]]) {
        self.elementLabel.text = obj;
    }
}

+ (CGSize)itemSizeWithContent:(NSString *)content
{
    NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:content];
    attr.yy_font = kFont;
    CGSize size = [attr boundSize:CGSizeMake(999, 999)];
    return CGSizeMake(size.width+SM_SIZE(15)*2, SM_SIZE(50));
}

@end
